package com.shunhe.storage.ui.statis;

import android.content.Context;
import android.os.Bundle;
import android.widget.TextView;

import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.ruitu.arad.base.BaseActivity;
import com.ruitu.arad.base.base_list.ListBaseAdapter;
import com.ruitu.arad.base.base_list.SuperViewHolder;
import com.shunhe.storage.R;
import com.shunhe.storage.dao.model.Statis;

import java.util.ArrayList;
import java.util.List;

// 统计页面
public class StatisActivity extends BaseActivity {
    private RecyclerView rcv_list;// 统计信息

    private List<Statis> statisList = new ArrayList<>();
    private StatisAdapter adapter;

    @Override
    protected int getLayoutRes() {
        return R.layout.activity_statis;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        rcv_list = findViewById(R.id.rcv_list);

        setHeadTitle("统计");

        Statis statis = new Statis();
        statis.setTitle("入库下单量18");
        statisList.add(statis);
        statis = new Statis();
        statis.setTitle("出库下单量20");
        statisList.add(statis);
        statis = new Statis();
        statis.setTitle("库存22");
        statisList.add(statis);
        statis = new Statis();
        statis.setTitle("入库接单量15");
        statisList.add(statis);
        statis = new Statis();
        statis.setTitle("出库接单量12");
        statisList.add(statis);

        adapter = new StatisAdapter(this);
        GridLayoutManager manager = new GridLayoutManager(this, 2);
        rcv_list.setLayoutManager(manager);
        rcv_list.setAdapter(adapter);
        adapter.setDataList(statisList);
    }

    private class StatisAdapter extends ListBaseAdapter<Statis> {

        public StatisAdapter(Context context) {
            super(context);
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_statis;
        }

        @Override
        public void onBindItemHolder(SuperViewHolder holder, int position) {
            TextView tv_title = holder.getView(R.id.tv_title);

            Statis statis = mDataList.get(position);
            tv_title.setText(statis.getTitle());
        }
    }
}